<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html" ; charset="utf-8" />
    <title>教务信息管理</title>
    <link href="../../../css/main.css" rel="stylesheet" type="text/css" />
    <link
      href="../../../bstable/css/bootstrap.min.css"
      rel="stylesheet"
      type="text/css"
    />
    <link
      href="../../../bstable/css/bootstrap-table.css"
      rel="stylesheet"
      type="text/css"
    />
  </head>

  <body>
    <div class="tabe_div">
      <p
        class="p_line text_ient"
        style="border-bottom: 0; margin-bottom: -10px"
      >
        <a class="find_a">报考类型：</a>
        <select class="form_select" style="padding-left: 1%" id="type">
          <option value="">全部</option>
          <option value="education">学历提升</option>
          <option value="occupation">职业技能</option>
          <option value="title">职称评审</option>
          <option value="train">执业资格</option>
        </select>
        <a class="find_a">审核状态：</a>
        <select class="form_select" style="padding-left: 1%" id="status">
          <option value="">全部</option>
          <option value="0">已保存</option>
          <option value="1">已提交</option>
          <option value="2">待财务审核</option>
          <option value="3">财务驳回</option>
          <option value="4">待教务审核</option>
          <option value="5">教务驳回</option>
          <option value="6">教务确认</option>
          <option value="8">财务确认</option>
        </select>
        <a class="find_a">老师姓名：</a>
        <input
          type="text"
          id="teacherName"
          class="form_input text_ient"
          placeholder="请填写老师姓名"
          maxlength="11"
        />
        <!-- <a class="find_a">学生手机号：</a>
            <input type="number" id="phone" class="form_input text_ient" placeholder="输入学生手机号" maxlength="11" /> -->
        <input type="button" value="查询" class="but_find" id="search" />
      </p>
      <p class="p_line text_ient" style="margin-bottom: -10px">
        <a class="find_a">学生姓名：</a>
        <input
          type="text"
          id="name"
          class="form_input text_ient"
          placeholder="请填写学生姓名"
          maxlength="18"
        />
        <a class="find_a">身份证号：</a>
        <input
          type="text"
          id="card"
          class="form_input text_ient"
          placeholder="请填写学生身份证号码"
          maxlength="18"
        />
      </p>
      <table
        data-url="json/data_alae_list.json"
        id="table"
        class="table_style"
        style="margin: 20px auto"
      ></table>
      <input
        type="button"
        value="已报考"
        style="margin-left: 20px; margin-bottom: 10px"
        class="but_find"
        id="baosong"
      />
    </div>
    <script src="../../../js/jquery.js"></script>
    <script src="../../../js/common.js"></script>
    <script src="../../../js/laydate-master/laydate.js"></script>
    <script src="../../../bstable/js/bootstrap.min.js"></script>
    <script src="../../../bstable/js/bootstrap-table.js"></script>
    <script src="../../../bstable/js/bootstrap-table-zh-CN.min.js"></script>
    <script type="text/javascript">
      localStorage.setItem("name", "教务管理/报考管理");

      $(function () {
        $("#search").on("click", function () {
          $("#table").bootstrapTable("refresh");
        });
        $("#baosong").on("click", function () {
          console.log("getSelect", $("#table").bootstrapTable("getSelections"));
          const selects = $("#table")
            .bootstrapTable("getSelections")
            .map((item) => {
              return item.studyId;
            });

          $.ajax({
            url: baseUrl + "studentInfo/setSubmissionFlag",
            method: "post",
            headers: {
              Authorization: JSON.parse(localStorage.getItem("userInfo")).token,
            },
            data: {
              studyIds: selects.toString(),
            },
            success: function (data) {
              $("#table").bootstrapTable("refresh");
              alert("提交成功");
            },
          });
        });
        var perm = JSON.parse(localStorage.getItem("userInfo")).perm;
        $("#table").bootstrapTable({
          method: "get",
          striped: true,
          singleSelect: false,
          url: baseUrl + "studentInfo/getStudentList",
          dataType: "json",
          pagination: true, //分页
          sidePagination: "server",
          pageSize: 10,
          pageNumber: 1,
          checkbox: true,
          search: false, //显示搜索框
          contentType: "application/x-www-form-urlencoded",
          // rowStyle:rowStyle,
          ajaxOptions: {
            headers: {
              Authorization: JSON.parse(localStorage.getItem("userInfo")).token,
            },
          },
          queryParams: function (params) {
            params.trainType = $("#type").val().trim();
            params.commitFlag = $("#status").val().trim()
              ? $("#status").val()
              : "";
            params.name = $("#name").val();
            params.idNo = $("#card").val();
            // params.mobile = $('#phone').val()
            params.teacherName = $("#teacherName").val();
            params.userType = "baokao";
            params.offset = params.offset / params.limit;
            delete params.order;
            return params;
          },
          responseHandler: function (res) {
            var list = res.data.result.records;
            var maps = {
              education: "学历提升",
              occupation: "职业技能",
              title: "职称评审",
              train: "执业资格",
            };
            list.forEach(function (item, i) {
              item.trainType = maps[item.trainType];
              !item && (list[i] = {});
            });
            return {
              rows: list,
              total: res.data.total,
            };
          },
          columns: [
            {
              checkbox: true,
              width: 80,
            },
            {
              field: "no",
              title: "序号",
              sortable: true,
              align: "center",
              formatter: function (value, row, index) {
                var pageSize =
                  $("#table").bootstrapTable("getOptions").pageSize;
                var pageNumber =
                  $("#table").bootstrapTable("getOptions").pageNumber;
                return pageSize * (pageNumber - 1) + index + 1;
              },
            },
            {
              title: "学生姓名",
              field: "name",
              align: "center",
              valign: "middle",
            },
            {
              title: "身份证号",
              field: "idNo",
              align: "center",
            },
            {
              title: "老师姓名",
              field: "teacherName",
              align: "center",
            },
            {
              title: "报考类型",
              field: "trainType",
              align: "center",
            },
            {
              title: "审核状态",
              field: "commitStr",
              align: "center",
            },
            {
              title: "业务进度",
              field: "businessProgress",
              align: "center",
              formatter: function (value, row, index) {
                const map = { 0: "报考", 1: "退款", 2: "分期缴费" };
                return map[row.businessProgress];
              },
            },
            {
              title: "报考进度",
              field: "submissionFlag",
              align: "center",
              formatter: function (value, row, index) {
                const map = { 0: "未报考", 1: "已报考" };
                return map[row.submissionFlag];
              },
            },
          ],
        });
      });

      function look(id, idNo, flag) {
        console.log(id);
        window.location.href =
          "../hotel/student.html?type=look&from=jiaowu&id=" +
          id +
          "&idNo=" +
          idNo +
          "&flag=" +
          flag;
      }

      function check(id, idNo, flag) {
        window.location.href =
          "../hotel/student.html?type=check&from=jiaowu&id=" +
          id +
          "&idNo=" +
          idNo +
          "&flag=" +
          flag;
      }

      // function rowStyle(item, index) {
      //     style = item.colorFlag == 1 ? {css:{'color':'#ed5565'}} : {}
      //     return style;
      // }
    </script>
  </body>
</html>
